﻿using System;
using System.Runtime.InteropServices;
using RuanRang.Media.Core.Internal.DataStructures;

namespace RuanRang.Media.Core.Internal
{
    /// <summary>
    /// VlcAudioOutput class
    /// </summary>
    public sealed class VlcAudioOutputDevice
    {
        /// <summary>
        /// Retreive the audio output name
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// Retreive the audio output description
        /// </summary>
        public string Description { get; private set; }

        /// <summary>
        /// Gets the next.
        /// </summary>
        /// <value>
        /// The next.
        /// </value>
        internal VlcAudioOutputDevice Next { get; private set; }

        /// <summary>
        /// VlcAudioOutput constrctor
        /// </summary>
        /// <param name="audioOutput">The libvlc audio output structure</param>
        internal VlcAudioOutputDevice(libvlc_audio_output_t audioOutput)
        {
            Name = audioOutput.psz_name;
            Description = audioOutput.psz_description;
            if (audioOutput.p_next == IntPtr.Zero) return;
#if SILVERLIGHT
                var next = new AudioOutput();
                Marshal.PtrToStructure(audioOutput.next, next);
#else
            var next = (libvlc_audio_output_t)Marshal.PtrToStructure(audioOutput.p_next, typeof(libvlc_audio_output_t));
#endif
            Next = new VlcAudioOutputDevice(next);
        }
    }
}
